/** 
 * @file main.c
 * Java class viewer.
 * classdesc - Descreve um arquivo do tipo .class de Java.
 *
 * Copyright (C) 2007 
 *   Renan Mendes Carvalho <aitherios@gmail.com>
 *   Pedro Marinho <pedro7x@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */



#include<stdio.h>
#include<stdlib.h>
#include"types.inc"
#include"simperr.h"
#include"javaclass.h"
#include"engine.h"
#include"heap.h"
#include"stack.h"

int 
main (int argc, char* argv[])
{
  FILE *file;
  class_file * cf;
  instance *it;


  
  file=fopen(argv[1],"rb");
  if(NULL!=file) {
    start_jvm_thread();
    cf=NULL;
    cf=read_class_file(file);
#   ifdef DEBUG
    print_class_file(stdout,cf);
    fflush(NULL);
#   endif
    it=load_instance(cf);
    execute_method(it,1,getsp_java());
    fclose(file);
    stop_jvm_thread();
  } else {
    printf("\nProblema abrir arquivo .class.");
  }
  
  return EXIT_SUCCESS;
}

